package com.joysuch.wwyt.baidu.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * 百度人脸识别状态码
 *
 * @author xsx
 * @version 1.0
 * @date 2023/3/14 18:13
 */
public enum BaiduCodeEnum {
    pic_not_has_face("222202", "pic not has face", "图片中没有人脸"),
    image_check_fail("222203", "image check fail", "无法解析人脸"),
    add_face_fail("222300", "add face fail", "人脸图片添加失败"),
    get_face_fail("222301", "get face fail", "获取人脸图片失败"),
    group_is_not_exist("223100", "group is not exist", "操作的用户组不存在"),
    group_list_is_too_large("223104", "group_list is too large", "group_list包含组数量过多"),
    face_is_already_exist("223105", "face is already exist", "该人脸已存在"),
    dst_group_is_not_exist("223111", "dst group is not exist", "目标用户组不存在"),
    face_is_covered("223113", "face is covered", "人脸有被遮挡"),
    face_is_fuzzy("223114", "face is fuzzy", "人脸模糊"),
    face_light_is_not_good("223115", "face light is not good", "人脸光照不好"),
    incomplete_face("223104", "incomplete face", "人脸不完整"),
    open_api_qps_request_limit_reached("18", "Open api qps request limit reached", "QPS超限额");

    private String code;
    private String errCode;
    private String errMsg;

    BaiduCodeEnum(String code, String errCode, String errMsg) {
        this.code = code;
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    private static final Map<String, BaiduCodeEnum> lookup = new HashMap<>();

    static {
        for (BaiduCodeEnum e : EnumSet.allOf(BaiduCodeEnum.class)) {
            lookup.put(e.code, e);
        }
    }

    public static BaiduCodeEnum find(String value) {
        return lookup.get(value);
    }
}
